package phidgetmotion;

import java.io.File;
import java.io.IOException;

import com.phidgets.PhidgetException;

import phidgetmotion.classifier.Model;
import phidgetmotion.gui.PhidgetMotionFrame;
import phidgetmotion.phidget.Accelerometer;

public class Main {
	
	public static String GNUPlotExecutable = "gnuplot";

	public static void main(String[] args) {
		if(args.length==1){
			GNUPlotExecutable = args[0];
		}
		try {
			Accelerometer.init();
		} catch (PhidgetException e) {
			Error.error(e);
		}
		
		File modelFile = new File("default.pmm");
		if(!modelFile.exists()){
			modelFile = null;
			Model.create(1000);
		}
		else {
			try{
				Model.load(modelFile);
			}catch (IOException e) {
				Error.error(e);
				modelFile = null;
				Model.create(1000);
			}
		}
		final PhidgetMotionFrame frame = new PhidgetMotionFrame(modelFile);
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            	frame.setVisible(true);
            }
        });

	}

}
